Skip to content

Emscripten bugfixes/nits#18562

Merged
LibretroAdmin merged 1 commit intolibretro:masterfrom
BinBashBanana:master
Jan 1, 2026
Merged

Emscripten bugfixes/nits#18562
LibretroAdmin merged 1 commit intolibretro:masterfrom
BinBashBanana:master

Conversation

@BinBashBanana
Copy link
Copy Markdown
Contributor

Apologies for the large PR (again...)

This fixes a number of minor bugs I found in the emscripten build, and there's a few tiny changes that aren't necessarily bugfixes.

Change list:

  • bugfix: Add missing HAVE_STB_VORBIS define
  • bugfix: Update BrowserFS to the latest (last) version on the single-threaded web player. Updating it gave some new warning messages, so I did a little refactoring and I think that the issue where the web player would load forever should be fixed now as well.
  • bugfix: command_set_shader now sets the video_shader_enable setting correspondingly.
  • bugfix: Fix the canvas being the wrong size for the first frame. This affected the XMB menu layout.
  • bugfix: Fix wake lock - it turns out it's lost whenever the tab is switched. I updated it to request wake lock again accordingly.
  • bugfix: Update the wake lock (suppress screensaver) whenever it's toggled in settings - not just when the video driver is inited.
  • bugfix: Fix GL context recovery in PROXY_TO_PTHREAD builds - I accidentally broke it in Emscripten core switching #18174 when I was refactoring the event listeners. (It should not have been proxied to the main thread.)
  • bugfix: Do glFinish explicitly in PROXY_TO_PTHREAD builds - without this, Firefox (at least on windows) would have a terrible GPU desync and was unusable in any menu driver except RGUI.
  • bugfix: Fix a rare bug that I could only get to work on Chrome on some intel integrated graphics where software-rendered cores that output a XRGB8888 framebuffer would become a black screen when using certain shaders (e.g. stock/bilinear, crt-caligari, crt-hyllian). There's something funny going on with alpha here, but I was able to fix it by forcing alpha to 1.
  • bugfix: Fix the fancy XMB ribbon on GLES3 for reals - turns out modern_pipeline_xmb_ribbon.glsl.vert.h was out of date compared to the legacy shader and wasn't displaying the ribbon.
  • bugfix: Fix off-by-one in RWebPad
  • bugfix: Fix the battery display not displaying until very late (up to 30 seconds) - there were 2 issues here: that in single-thread builds, the timer that emscripten gives has an origin of when the page loaded rather than 1970, so current time minus last update time (default 0) would not be greater than the threshold until the page has been loaded for 30 seconds. The other issue was that since the battery state is fetched asynchronously, the first check might not get anything. I reduced the battery check interval for emscripten to 1 second.
  • nit: Set HAVE_RUNAHEAD by default - it was also missing from Makefile.emscripten
  • nit: Rename emscripten/pre.js to emscripten/extern_pre.js for consistency.
  • nit: Clean up some of my silly code in rwebaudio.c and platform_emscripten.c
  • nit: Always use RGBA textures for RWebCam - not just for consistency, but apparently 3-channel (especially RGB888) textures can be much slower in WebGL.
  • nit: Remove use of Module.onRuntimeInitialized - waiting for the javascript module to load is a better and potentially less buggy alternative.
  • "feature": Add basic JSPI support - this is a new, lighter alternative to Asyncify, but it currently requires a patched emscripten toolchain. It's currently only enabled in chromium-based browsers, but I hope it will be viable in the future.
  • "feature": Add closure compiler support - I think this was also supported in the past but I can't find it. It needed some special extern files to prevent the minification from breaking BrowserFS. The closure compiler reduces the output javascript size by around 50%!
  • "feature": Use UBSan in debug builds by default if possible
  • "feature": Add a "deferred" sleep function - similar to the "fake block" that RWebAudio and AudioWorklet already use in non-asyncify, non-proxy-to-pthread builds, this is used for when VSync is off (in runloop.c) and it drastically reduces CPU usage when using a limited fast-forward rate (or any time VSync is off and there's no audio that's already doing the blocking).
  • Update the emscripten readme a bit
  • Update the core list

Some thoughts:

  • Would it be better to move the emscripten_mainloop definition back to platform_emscripten.c?
  • Is the setImmediate workaround in extern_pre.js still needed?
  • Should suppress screensaver be enabled by default? I think linux is the only other platform that it's supported on, and I think it might be good if it were disabled by default for emscripten builds.

Happy new year all!
CC @JoeOsborn

P.S. @LibretroAdmin - I think now with the aforementioned Firefox bug fixed, the new web player is 100% ready. How should we proceed? Should I make an issue for tracking?

@SternXD
Copy link
Copy Markdown
Contributor

SternXD commented Jan 1, 2026

Thanks for doing the HAVE_STB_VORBIS I was scratching my head trying to figure out how to add it since I don't use makefiles at all nor have used them before 😅

@LibretroAdmin LibretroAdmin merged commit 3f35d2c into libretro:master Jan 1, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants